

 
		 **************************************************************
		 **															 **
		 ** Paper: Freedom of Foreign Movement and Human Trafficking **
		 **														     **
		 ** Authors: Sam R. Bell & Richard W. Frank 				 **
		 **															 **
		 ** Date: May 11, 2021										 **
		 **															 **
		 ** Task: Figure 3-CIRI freedom of foreign movement map		 **
		 **															 **
		 **************************************************************
 
			
	** This is a do file to merge country-level data with QGIS country-level codes **
	

	clear
	version 16.1
	set seed 1234
 
	** first you need to keep just the year you want to map **

	use "vdem_move.dta", clear
	tab year
	keep if year==2011
	rename COWcode ccode
	sort ccode 
	duplicates report ccode year
	browse if ccode==ccode[_n-1]
	drop if ccode==.
	
	keep ccode country_name v2clslavem v2clslavef v2clfmove v2cldmovem v2cldmovew v2xcl_dmove v2xcl_slave_codelow
	save "VDEM move 2011 only.dta", replace
	
	** then opening the ccode to world border name file 
		
	import excel "world borders ccode zipper.xlsx", sheet("world borders ccode zipper") firstrow clear

	** then you merge in the country-level data you want to map **
 
	merge m:1 ccode using 	"/Users/rich/Dropbox/Data/V-DEM/data/VDEM move 2011 only.dta"
	drop _merge
	order ADMIN ctry country_name
	sort ccode
	
	replace ADMIN=ctry if ADMIN=="" & ctry~=""
	replace ADMIN=country_name if ADMIN=="" & country_name~=""	
	drop country_name ctry
	drop if ccode==.

	** export a csv to add as a layer in QGIS **
		
	export delimited using "vdem_formov_2011.csv", replace

	
	
	
	
